package com.happy_hao.msg.controller;


import com.happy_hao.msg.common.Result;
import com.happy_hao.msg.dto.SenderRequest;
import com.happy_hao.msg.service.SenderService;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/msg/sender")
public class SenderController {

    @Resource
    private SenderService senderService;

    @PutMapping("/addSender")
    public Result addSender(@Valid @RequestBody SenderRequest senderRequest){
        return senderService.addSender(senderRequest);
    }

    @GetMapping("/getAllSenders")
    public Result getAllSenders(){
        return senderService.getAllSenders();
    }

    @DeleteMapping("/deleteSender")
    public Result deleteSender(@RequestParam("username") String username){
        return senderService.deleteSender(username);
    }
    
    @RequestMapping ("/updateSender")
    public Result updateSender(@Valid @RequestBody SenderRequest senderRequest){
        return senderService.updateSender(senderRequest);
    }

}
